package com.eboss.sbs.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.eboss.sbs.R;
import com.eboss.sbs.model.CouponActivateShop;

import java.util.List;

public class CouponActivateShopListAdapter extends BaseAdapter {

	private Context context;
	private List<CouponActivateShop> datas;
	private LayoutInflater mInflater;
	private ViewHolder holder = null;
	
	public CouponActivateShopListAdapter(){}
	public CouponActivateShopListAdapter(Context context, List<CouponActivateShop> datas){
		this.context = context;
		this.datas = datas;
		this.mInflater = LayoutInflater.from(this.context);
	}
	
	@Override
	public int getCount() {
		if(datas!=null&&datas.size()>0)return datas.size();
		else return 0;
	}

	@Override
	public CouponActivateShop getItem(int position) {
		return datas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		CouponActivateShop data = datas.get(position);
		
		mInflater = LayoutInflater.from(context);

		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.listitem_coupon_activate_shop_item, null);
			
			holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
			holder.tv_hasjoin = (TextView) convertView.findViewById(R.id.tv_hasjoin);
			
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.tv_name.setText(data.getName());
		holder.tv_hasjoin.setText(data.getHasJoin());

		return convertView;
	}

	public final class ViewHolder {
		private TextView tv_name;
		private TextView tv_hasjoin;
	}

}
